var f = "";
$(function(){
	var skuId = localStorage.getItem("skuId");
	$.ajax({
		url:server_url+'/rest/favorite/isFavorite.do',
		data:{userId:userid,skuId:skuId,rand:Math.random()},
		success:function(data){
			console.log(data)
			if(data.data == 'yes'){
				$('.pro_name > div').children('p').addClass('sel');
			}
		},
		fail:function(){
			console.log("fail")
		}
	})
});
$('.pro_name > div').click(function() {
	if(f) {
		clearTimeout(f);
	} 
	f = setTimeout(function() {
		var skuId = localStorage.getItem("skuId");
		$.ajax({
			url:server_url+'/rest/favorite/addToFavorite.do',
			data:{userId:userid,skuId:skuId,rand:Math.random()},
			success:function(){
				if($('.pro_name > div').children('p').hasClass('sel')) {
					$('.pro_name > div').children('p').removeClass('sel');
				} else {
					$('.pro_name > div').children('p').addClass('sel');
				}
			}

		})
	}, 80);
});